package cn.taketoday.live.thread.core;

import org.apache.tomcat.util.buf.HexUtils;

import cn.taketoday.live.config.GlobalData;

/**
 * @author BanqiJane
 */
public class HeartByteThread extends Thread {
  //	private Logger LOGGER = LogManager.getLogger(HeartByteThread.class);
//	Websocket client;
//	String heartByte;
  public volatile boolean HFLAG = false;

//	public HeartByteThread(Websocket client, String heartByte) {
//		super();
//		this.client = client;
//		this.heartByte = heartByte;
//	}

  @Override
  public void run() {
    super.run();
    while (!HFLAG) {
      if (HFLAG) {
        return;
      }
      if (GlobalData.webSocketProxy.isOpen()) {
        try {
          Thread.sleep(30000);
          GlobalData.webSocketProxy.send(HexUtils.fromHexString(GlobalData.heartByte));
        }
        catch (Exception e) {

        }
      }

    }
  }

}
